﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class WebControl_UpdateGroupAccount : System.Web.UI.UserControl
{
    private string getIdGroup = null;
    private string getGroupName = null;
    private string getDescription = null;
    ListAndProcessData wsv = new ListAndProcessData();
    protected void Page_Load(object sender, EventArgs e)
    {    
        if(!IsPostBack)
        {
            getIdGroup = Request.QueryString["idgroup"].ToString();
            getGroupName = Request.QueryString["namegroup"].ToString();
            getDescription = Request.QueryString["description"].ToString();
            txtdescription.Text = getDescription;
            var groupaccount = wsv.loadGroupName();
            foreach (var item in groupaccount)
            {
                DropDownList2.Items.Add(item.Groupname);
            }
        }              
    }

    protected void btsubmit_Click(object sender, EventArgs e)
    {
        getIdGroup = Request.QueryString["idgroup"].ToString();
        bool check = wsv.UpdateGroupAccount(Convert.ToInt32(getIdGroup), DropDownList2.SelectedValue, txtdescription.Text.ToString());
        if (check)
        {
            Response.Redirect("ShowGroupAccount.aspx");

        }
        else
        {
            Response.Redirect("Loi.aspx");
        }
    }
}